<template>
  <div class="balance-popup" v-show="isShow">
    <div class="popup-header">
      <!-- <img src="@/assets/images/yueHome.png" alt="" class="header-icon"> -->
      <h2>账户余额</h2>
    </div>
    <div style="height:5px;background: #ff6600;border-radius: 5px;margin-bottom:15px;"></div>
    <div class="balance-content">        
      <div class="balance-item balance-item-b" v-if="$store.getters.userType == '03'">
        <p class="item-title">余额</p>
        <p class="item-amount">{{ data.amount }}</p>
        <p class="item-desc">余额</p>
      </div>
        <div class="balance-item balance-item-b">
        <p class="item-title">可用金额</p>
        <p class="item-amount">{{ data.availableAmount }}</p>
        <p class="item-desc">可用金额</p>
      </div>
      <div class="balance-item " :class="[{'balance-item-b': $store.getters.userType == '02'}]" >
        <p class="item-title">冻结金额</p>
        <p class="item-amount">{{ data.freezeAmount }}</p>
        <span class="frozen-tag">冻结金额</span>
      </div>
      <div class="balance-item" v-if="$store.getters.userType == '02'">
        <p class="item-title">固定额度</p>
        <p class="item-amount">{{ data.fixedAmount }}</p>
        <p class="item-desc">固定额度</p>
      </div>
    </div>
    <div class="popup-footer">
      <button class="withdraw-btn" @click="handleWithdraw">提现 ➜</button>
      <button class="progress-btn" @click="handleCheckProgress">查看提现进度</button>
    </div>
  </div>
</template>

<script>
// import {getTradeCount} from '@/api/home/home';

export default {
  name: 'BalancePopup',
  data() {
    return {
      isShow: false,
      data: {amount:0,availableAmount:0,frozenAmount:0,fixedAmount:0}
    };
  },
  created() {
    // 获取交易记录数量
    getTradeCount().then(res => {
      if (res.code == 200) {
        this.data = res.data;

      }
    });
  },
  methods: {
    showPopup() {
      this.isShow = true;
    },
    hidePopup() {
      this.isShow = false;
    },
    handleWithdraw() {
      // 提现逻辑
      console.log('执行提现操作');
    },
    handleCheckProgress() {
      // 查看提现进度逻辑
      console.log('查看提现进度');
    },
  },
};
</script>

<style scoped>
.balance-popup {
  width: 600px;
  background: linear-gradient(to bottom, #fff3e6, #ffcc99);
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
}
.popup-header {
  display: flex;
  align-items: center;
  margin-bottom: 20px;
}
.header-icon {
  height: 26px;
  margin-right: 10px;
}
.popup-header h2 {
  flex: 1;
  color: #ff6600;
  font-size: 24px;
}
.search-btn {
  background-color: #ff6600;
  color: #fff;
  border: none;
  border-radius: 5px;
  padding: 8px 16px;
  cursor: pointer;
}
.balance-content {
  display: flex;
  background: #ffffff60;
  padding:10px;
  border-radius: 15px;
  justify-content: space-around;
  margin-bottom: 20px;
}
.balance-item {
  text-align: center;
  position: relative;
  width:33.33%;
}
.balance-item-b::before{
    content: "";
    width:2px;
    height:60px;
    background: linear-gradient(to bottom, #cecccc20,#96949460,#cecccc20);
    position:absolute;
    right:0;
    bottom:15px;
}
.item-title {
  color: #999;
  margin-bottom: 5px;
}
.item-amount {
  font-size: 28px;
  color: #ff6600;
  font-weight: bold;
  margin-bottom: 5px;
}
.frozen-tag {
  background-color: #66cc66;
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
}
.popup-footer {
  display: flex;
  justify-content: space-around;
}
.withdraw-btn {
    width:45%;
  background-color: #3c9cff;
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 10px 20px;
  cursor: pointer;
  font-size: 16px;
}
.progress-btn {
    width:45%;
  background-color: #ffffff70;
  color: #666;
  border: none;
  border-radius: 50px;
  padding: 10px 20px;
  cursor: pointer;
  font-size: 16px;
}
</style>